use axum::Router;
use tokio::net::TcpListener;

pub struct Server{
  app:Router,
   listener:TcpListener,
}
impl Server{
pub async fn new(addr:&str,app:Router)->Result<Self,std::io::Error> {
    let listener = TcpListener::bind(addr).await?;
Ok(Self{app,listener})
}
 pub async fn run(self)->Result<(),std::io::Error>{
  axum::serve(self.listener, self.app).await?;
  Ok(())
 }
}